package com.example.regex.term2;

/**
 * 判断有效的电话号码
 */
public class Client {

    public static boolean isValidPhoneNumber(String number) {
        // 判断是否是 11 位
        if (number.length() != 11) return false;
        // 判断每一位是否全为数字
        for (int i = 0; i < number.length(); i++) {
            if (number.charAt(i) < '0' || number.charAt(i) > '9') return false;
        }
        return true;
    }

    public static boolean isValidPhoneNumber1(String number) {
        return number.matches("\\d{11}");
    }

    public static void main(String[] args) {
        System.out.println(isValidPhoneNumber("15084882347"));
        System.out.println(isValidPhoneNumber1("15084882347"));

        System.out.println(isValidPhoneNumber("1508488234"));
        System.out.println(isValidPhoneNumber1("1508488234"));
    }

}
